//
//  discountTableViewCell.m
//  Journey
//
//  Created by dllo on 16/5/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "discountTableViewCell.h"
#import "discountCollectionViewCell.h"
@interface discountTableViewCell ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property(nonatomic,strong)BaseCollectionView *disCollectionView;
@property(nonatomic,strong)NSMutableArray *dataArray;
@end

@implementation discountTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createDiscount];
    }
    return self;
}

-(void)createDiscount
{
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(180 * WIDTHC,100 * WIDTHC);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.minimumLineSpacing = 10;
    flowLayout.minimumInteritemSpacing = 20;
    self.disCollectionView = [[BaseCollectionView alloc]initWithFrame:self.contentView.bounds collectionViewLayout:flowLayout];
 self.disCollectionView .dk_backgroundColorPicker = DKColorPickerWithRGB(0xFFFFFF,0x363636);
    self.disCollectionView.delegate = self;
    self.disCollectionView.dataSource = self;
    [self.disCollectionView registerClass:[discountCollectionViewCell class] forCellWithReuseIdentifier:@"discountCell"];
    [self.contentView addSubview:self.disCollectionView];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.disCollectionView.frame = CGRectMake(15 * WIDTHC, 15 * WIDTHC, self.contentView.frame.size.width - 30, self.contentView.frame.size.height - 20);
}
//cell数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    discountCollectionViewCell *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"discountCell" forIndexPath:indexPath];
    
    
    item.detail = self.dataArray[indexPath.row];
    
  
    return item;
}


-(void)setTempArray:(NSMutableArray *)tempArray{
    
    _tempArray = tempArray;
    
    self.dataArray = [NSMutableArray array];
    self.dataArray = [NSMutableArray arrayWithArray:_tempArray];
    [self.disCollectionView reloadData];
}







@end
